/*
 * AbatorRunner.java
 *
 * Created on October 30, 2007, 2:50 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package jia.tools;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.ibatis.abator.api.Abator;
import org.apache.ibatis.abator.config.AbatorConfiguration;
import org.apache.ibatis.abator.config.xml.AbatorConfigurationParser;
import org.apache.ibatis.abator.exception.InvalidConfigurationException;
import org.apache.ibatis.abator.exception.XMLParserException;
import org.apache.ibatis.abator.internal.DefaultShellCallback;

/**
 *
 * @author gryffonx
 */
public class AbatorRunner {
    
    /** Creates a new instance of AbatorRunner */
    public AbatorRunner() throws InvalidConfigurationException {
        
   List warnings = new ArrayList();  // Abator will add Strings to this list
   boolean overwrite = true;
   File configFile = new File("src/jia/tools/AbatorConfig.xml");
   AbatorConfigurationParser cp = new AbatorConfigurationParser(warnings);
        AbatorConfiguration config = null;
        try {
            config = cp.parseAbatorConfiguration(configFile);
        } catch (XMLParserException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
   DefaultShellCallback callback = new DefaultShellCallback(overwrite);
   Abator abator = new Abator(config, callback, warnings);
        try {
            abator.generate(null);        
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }        
        
        //set the runtime parameters, load the config file and execute the process
    }
    
    
    public static void main(String[] args){
        try {
            //insert runtime code here
            new AbatorRunner();
        } catch (InvalidConfigurationException ex) {
            Logger.getLogger(AbatorRunner.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
